
import { defineStore } from 'pinia'

// 用于存放用户相关信息
export const useUser = defineStore("userInfo", {
  state: () => {
    return {
      // 用户信息
      user: {
        userHeader: '',
        user_id: '',
        userName: '',
        userType: ''
      }
    }
  },
  actions: {
    // 设置用户信息
    upUserHeader(val) {
      console.log(val);
      this.user.userHeader = val
    },
    setUser(val) {
      this.user.userHeader = val.userHeader
      this.user.user_id = val.userId
      this.user.userName = val.username
      this.user.userType = val.type
    },
    // 重置用户信息
    reset() {
      this.user.userHeader = ''
      this.user.user_id = ''
      this.user.userName = ''
      this.user.userType = ''
    },
  }

})